import fetch from "../utils/fetch";
import {API_BASE_URL} from "@/config";


export function searchCustomer(data) {
  return fetch({
    url: "wechat/staff/searchCustomer",
    method: "post",
    data
  });
}

export function getCustomerRead(data) {
  return fetch({
    url: "wechat/staff/getCustomerRead",
    method: "post",
    data
  });
}

export function contractCreate(data) {
  return fetch({
    url: "wechat/staff/contractCreate",
    method: "post",
    data
  });
}

export function getRooms(data) {
  return fetch({
    url: "wechat/staff/getRooms",
    method: "post",
    data
  });
}

export function setUser(data) {
  return fetch({
    url: "wechat/staff/setUser",
    method: "post",
    data
  });
}

export function contractSave(data) {
  return fetch({
    url: "wechat/staff/contractSave",
    method: "post",
    data
  });
}

export function beforeSave(data) {
  return fetch({
    url: "wechat/staff/beforeSave",
    method: "post",
    data
  });
}

export function checkoutHouseEndTime(data) {
  return fetch({
    url: "wechat/staff/checkoutHouseEndTime",
    method: "post",
    data
  });
}

export function checkoutEndMonth(data) {
  return fetch({
    url: "wechat/staff/checkoutEndMonth",
    method: "post",
    data
  });
}

export function saveBefore(data) {
  return fetch({
    url: "wechat/saveBefore",
    method: "post",
    data
  });
}

export function contractSubsist(data) {
  return fetch({
    url: "wechat/subsist_save",
    method: "post",
    data
  });
}

export function checkEndMonth(data) {
  return fetch({
    url: "wechat/checkEndMonth",
    method: "post",
    data
  });
}

export function checkEndDateForHouse(data) {
  return fetch({
    url: "wechat/checkEndDateForHouse",
    method: "post",
    data
  });
}


export function getWechatUser(data) {
  return fetch({
    url: "wechat/get_wechat_user",
    method: "get",
    params: data
  });
}

// 公众号授权重定向链接
export function redirectOCAuth(redirectUrl = window.location.href) {
  const url = `${API_BASE_URL}/wechat/autho?url=${encodeURIComponent(
    redirectUrl
  )}`;
  window.location.replace(url);
}

// 获取公众号jssdk签名
export function getJSSDKSign(data) {
  return fetch({
    url: "wechat/get_jssdk",
    method: "get",
    params: {
      url: location.href.split("#")[0]
    }
  });
}

export function getSmsCode(data) {
  return fetch({
    url: "wechat/sms_code",
    method: "post",
    data
  });
}

export function wechatUnbind(data) {
  return fetch({
    url: "wechat/unbind",
    method: "post",
    data
  });
}

export function wechatMain(data) {
  return fetch({
    url: "wechat/main",
    method: "get",
    params: data
  });
}

export function wechatBills(data) {
  return fetch({
    url: "wechat/bills",
    method: "get",
    params: data
  });
}

export function wechatPay(data) {
  return fetch({
    url: "wechat/pay",
    method: "post",
    data
  });
}

export function wechatBillRead(data) {
  return fetch({
    url: "wechat/bill_read",
    method: "get",
    params: data
  });
}

export function getDorm(data) {
  return fetch({
    url: "wechat/my_rooms",
    method: "get",
    params: data
  });
}

export function wechatCustomer(data) {
  return fetch({
    url: "wechat_customer",
    method: "post",
    data
  });
}

export function wechatCustomerCreate(data) {
  return fetch({
    url: "wechat_customer/create",
    method: "get",
    params: data
  });
}

export function home(data) {
  return fetch({
    url: "wechat/index",
    method: "get",
    params: data
  });
}